package com.js.nickcar.module.addcar.series;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.js.nickcar.R;
import com.js.nickcar.base.BaseHolder;
import com.js.nickcar.entity.remote.CarSeriesBean;
import com.js.nickcar.widget.recycler.BaseRecyclerAdapter;

import java.util.List;

/**
 * Created by LZY on 2017/9/30.
 */
public class CarBrandSeriesAdapter extends BaseRecyclerAdapter<CarSeriesBean> {
    public CarBrandSeriesAdapter(Context context) {
        super(context, NEITHER);
    }

    @Override
    protected RecyclerView.ViewHolder onCreateDefaultViewHolder(ViewGroup parent, int type) {
        return new CarBrandDetailHolder(mInflater.inflate(R.layout.item_car_brand_detail, parent, false));
    }

    @Override
    protected void onBindDefaultViewHolder(RecyclerView.ViewHolder viewholder, CarSeriesBean item, int position) {
        CarBrandDetailHolder holder = (CarBrandDetailHolder) viewholder;
        holder.tvCarName.setText(item.getSeries_name());
        Glide.with(mContext)
                .load(item.getImage())
                .fitCenter()
                .into(holder.ivCar);
    }

    private class CarBrandDetailHolder extends BaseHolder {
        public final ImageView ivCar;
        public final TextView tvCarName;

        public CarBrandDetailHolder(View view) {
            super(view);
            ivCar = findViewById(R.id.iv_car);
            tvCarName = findViewById(R.id.tv_car_name);
        }
    }
}
